package com.glodon.paas.storage;

import java.io.InputStream;
import java.util.List;

public interface BulkStorage {
	
    //默认分块大小 5M
    public static final long BLOCK_SIZE=1024*1024*5;
	
	/**
	 * write object to the path
	 * @param key
	 * @param input
	 * @param length
	 * @
	 */
	WriteResult write(String key, InputStream object, long length) ;
	
	/**
	 * get object by path
	 * @param path
	 * @return
	 */
	ReadResult read(String key) ;
	
	/**
	 * check if partial read is supported
	 * @return
	 */
	boolean isPartialReadSupported();
	
	/**
	 * get partial object by path
	 * @param key
	 * @param start
	 * @param end
	 * @return
	 */
	ReadResult read(String key, long start, long end) ;
	
	/**
	 * delete a object
	 * @param key
	 * @
	 */
	void delete(String key) ;
	
	
	/**
	 * @return
	 */
	boolean isMultiPartUploadSupported();
	
	/**
	 * @param key Key for target object
	 * @return
	 * @
	 */
	InitResult initMultiPartUpload(String key) ;
	
	/**
	 * @param handle
	 * @param part
	 * @param is
	 * @return
	 * @
	 */
	WriteResult uploadPart(InitResult handle, Part part, InputStream is) ;
	
	/**
	 * 
	 * @param handle
	 * @return
	 */
	WriteResult completeMultiPartUpload(InitResult handle, List<Part> parts) ;
	
	
	/**
	 * @param key
	 * @param uploadId
	 * @
	 */
	void abortMultiPartUpload(InitResult handle) ;
}
